<template>
  <div :class="getClass">
    <template v-if="canFullscreen">
      <fullscreen-exit-outlined role="full" @click="handleFullScreen" v-if="fullScreen" />
      <fullscreen-outlined role="close" @click="handleFullScreen" v-else />
    </template>
    <close-outlined @click="handleCancel" />
  </div>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { FullscreenExitOutlined, FullscreenOutlined, CloseOutlined } from '@ant-design/icons-vue';

  export default defineComponent({
    name: 'ModalClose',
    components: { FullscreenExitOutlined, FullscreenOutlined, CloseOutlined },
    props: {
      canFullscreen: { type: Boolean, default: true },
      fullScreen: { type: Boolean },
    },
    emits: ['cancel', 'fullscreen'],
    computed: {
      getClass() {
        return [
          'basic-modal-close',
          `basic-modal-close--custom`,
          {
            [`basic-modal-close--can-full`]: this.canFullscreen,
          },
        ];
      },
    },
    methods: {
      handleCancel() {
        this.$emit('cancel');
      },
      handleFullScreen(e: Event) {
        e?.stopPropagation();
        e?.preventDefault();
        this.$emit('fullscreen');
      },
    },
  });
</script>
<style lang="less">
  .basic-modal-close {
    display: flex;
    height: 95%;
    align-items: center;

    > span {
      margin-left: 48px;
      font-size: 16px;
    }

    &--can-full {
      > span {
        margin-left: 12px;
      }
    }

    &:not(&--can-full) {
      > span:nth-child(1) {
        &:hover {
          font-weight: 700;
        }
      }
    }

    & span:nth-child(1) {
      display: inline-block;
      padding: 10px;

      &:hover {
        color: @primary-color;
      }
    }

    & span:nth-child(2) {
      &:hover {
        color: @error-color;
      }
    }
  }
</style>
